//
//  UIView+SEGLayerConfig.m
//  Commom
//
//  Created by 梁学彰 on 2019/10/8.
//

#import "UIView+SEGLayerConfig.h"
#import "SEGUserImageViewManager.h"
#import <objc/runtime.h>

@implementation UIView (SEGLayerConfig)

- (void)seg_configWithRadius:(CGFloat)radius {
    if ([SEGUserImageViewManager isUserImageViewWithRoundness]) {
        //如果是圆形 就设置半高
        [self layoutIfNeeded];
        if (self.frame.size.height > 0) {
            self.layer.cornerRadius = self.frame.size.width/2.0;
        }else {
            self.layer.cornerRadius = radius;
        }
    }else {
        //方的 就设置圆角
        if (radius < 0.01) {
            radius = [SEGUserImageViewManager getRadiusWithPlat];
        }
        [self layoutIfNeeded];
        if (radius == self.frame.size.width/2.0) {
            radius = [SEGUserImageViewManager getRadiusWithPlat];
        }
        self.layer.cornerRadius = radius;
    }
    self.layer.masksToBounds = YES;
}



@end
